home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Dev / SpeakFreely_Src / gsm / src / gsm_implode.c < prev    next >
C/C++ Source or Header  |  2000-05-27  |  6KB  |  281 lines

  1. /*
  2.  * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
  3.  * Universitaet Berlin.  See the accompanying file "COPYRIGHT" for
  4.  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  5.  */
  6.  
  7. /* $Header: /home/kbs/jutta/src/gsm/gsm-1.0/src/RCS/gsm_implode.c,v 1.1 1992/10/28 00:15:50 jutta Exp $ */
  8.  
  9. #include "private.h"
  10.  
  11. #include "gsm.h"
  12. #include "proto.h"
  13.  
  14. void gsm_implode P3((s, source, c), gsm s, gsm_signal * source, gsm_byte * c)
  15. {
  16.     /*    variable    size    index
  17.  
  18.         GSM_MAGIC    4    -
  19.  
  20.         LARc[0]        6    0
  21.         LARc[1]        6    1
  22.         LARc[2]        5    2
  23.         LARc[3]        5    3
  24.         LARc[4]        4    4
  25.         LARc[5]        4    5
  26.         LARc[6]        3    6
  27.         LARc[7]        3    7
  28.  
  29.         Nc[0]        7    8
  30.         bc[0]        2    9
  31.         Mc[0]        2    10
  32.         xmaxc[0]    6    11
  33.         xmc[0]        3    12
  34.         xmc[1]        3    13
  35.         xmc[2]        3    14
  36.         xmc[3]        3    15
  37.         xmc[4]        3    16
  38.         xmc[5]        3    17
  39.         xmc[6]        3    18
  40.         xmc[7]        3    19
  41.         xmc[8]        3    20
  42.         xmc[9]        3    21
  43.         xmc[10]        3    22
  44.         xmc[11]        3    23
  45.         xmc[12]        3    24
  46.  
  47.         Nc[1]        7    25
  48.         bc[1]        2    26
  49.         Mc[1]        2    27
  50.         xmaxc[1]    6    28
  51.         xmc[13]        3    29
  52.         xmc[14]        3    30
  53.         xmc[15]        3    31
  54.         xmc[16]        3    32
  55.         xmc[17]        3    33
  56.         xmc[18]        3    34
  57.         xmc[19]        3    35
  58.         xmc[20]        3    36
  59.         xmc[21]        3    37
  60.         xmc[22]        3    38
  61.         xmc[23]        3    39
  62.         xmc[24]        3    40
  63.         xmc[25]        3    41
  64.  
  65.         Nc[2]        7    42
  66.         bc[2]        2    43
  67.         Mc[2]        2    44
  68.         xmaxc[2]    6    45
  69.         xmc[26]        3    46
  70.         xmc[27]        3    47
  71.         xmc[28]        3    48
  72.         xmc[29]        3    49
  73.         xmc[30]        3    50
  74.         xmc[31]        3    51
  75.         xmc[32]        3    52
  76.         xmc[33]        3    53
  77.         xmc[34]        3    54
  78.         xmc[35]        3    55
  79.         xmc[36]        3    56
  80.         xmc[37]        3    57
  81.         xmc[38]        3    58
  82.  
  83.         Nc[3]        7    59
  84.         bc[3]        2    60
  85.         Mc[3]        2    61
  86.         xmaxc[3]    6    62
  87.         xmc[39]        3    63
  88.         xmc[40]        3    64
  89.         xmc[41]        3    65
  90.         xmc[42]        3    66
  91.         xmc[43]        3    67
  92.         xmc[44]        3    68
  93.         xmc[45]        3    69
  94.         xmc[46]        3    70
  95.         xmc[47]        3    71
  96.         xmc[48]        3    72
  97.         xmc[49]        3    73
  98.         xmc[50]        3    74
  99.         xmc[51]        3    75
  100.     */
  101.  
  102.  
  103. #define    LARc    source
  104.  
  105.     *c++ =   ((GSM_MAGIC & 0xF) << 4)        /* 1 */
  106.            | ((LARc[0] >> 2) & 0xF);
  107.     *c++ =   ((LARc[0] & 0x3) << 6)
  108.            | (LARc[1] & 0x3F);
  109.     *c++ =   ((LARc[2] & 0x1F) << 3)
  110.            | ((LARc[3] >> 2) & 0x7);
  111.     *c++ =   ((LARc[3] & 0x3) << 6)
  112.            | ((LARc[4] & 0xF) << 2)
  113.            | ((LARc[5] >> 2) & 0x3);
  114.     *c++ =   ((LARc[5] & 0x3) << 6)
  115.            | ((LARc[6] & 0x7) << 3)
  116.            | (LARc[7] & 0x7);
  117.  
  118. #define    Nc    (source + 8)
  119.  
  120.     *c++ =   ((Nc[0] & 0x7F) << 1)
  121.  
  122. #define    bc    (source + 9)
  123.  
  124.            | ((bc[0] >> 1) & 0x1);
  125.     *c++ =   ((bc[0] & 0x1) << 7)
  126.  
  127. #define    Mc    (source + 10)
  128.  
  129.            | ((Mc[0] & 0x3) << 5)
  130.  
  131. #define    xmaxc    (source + 11)
  132.  
  133.            | ((xmaxc[0] >> 1) & 0x1F);
  134.     *c++ =   ((xmaxc[0] & 0x1) << 7)
  135.  
  136. #define    xmc    (source + 12)
  137.  
  138.            | ((xmc[0] & 0x7) << 4)
  139.            | ((xmc[1] & 0x7) << 1)
  140.            | ((xmc[2] >> 2) & 0x1);
  141.     *c++ =   ((xmc[2] & 0x3) << 6)
  142.            | ((xmc[3] & 0x7) << 3)
  143.            | (xmc[4] & 0x7);
  144.     *c++ =   ((xmc[5] & 0x7) << 5)            /* 10 */
  145.            | ((xmc[6] & 0x7) << 2)
  146.            | ((xmc[7] >> 1) & 0x3);
  147.     *c++ =   ((xmc[7] & 0x1) << 7)
  148.            | ((xmc[8] & 0x7) << 4)
  149.            | ((xmc[9] & 0x7) << 1)
  150.            | ((xmc[10] >> 2) & 0x1);
  151.     *c++ =   ((xmc[10] & 0x3) << 6)
  152.            | ((xmc[11] & 0x7) << 3)
  153.            | (xmc[12] & 0x7);
  154.  
  155. #undef    Nc
  156. #define    Nc    (source + 25 - 1)
  157.  
  158.     *c++ =   ((Nc[1] & 0x7F) << 1)
  159.  
  160. #undef    bc
  161. #define    bc    (source + 26 - 1)
  162.  
  163.            | ((bc[1] >> 1) & 0x1);
  164.     *c++ =   ((bc[1] & 0x1) << 7)
  165.  
  166. #undef    Mc
  167. #define    Mc    (source + 27 - 1)
  168.  
  169.            | ((Mc[1] & 0x3) << 5)
  170.  
  171. #undef     xmaxc
  172. #define    xmaxc    (source + 28 - 1)
  173.  
  174.            | ((xmaxc[1] >> 1) & 0x1F);
  175.     *c++ =   ((xmaxc[1] & 0x1) << 7)
  176.  
  177. #undef    xmc
  178. #define    xmc    (source + 29 - 13)
  179.  
  180.            | ((xmc[13] & 0x7) << 4)
  181.            | ((xmc[14] & 0x7) << 1)
  182.            | ((xmc[15] >> 2) & 0x1);
  183.     *c++ =   ((xmc[15] & 0x3) << 6)
  184.            | ((xmc[16] & 0x7) << 3)
  185.            | (xmc[17] & 0x7);
  186.     *c++ =   ((xmc[18] & 0x7) << 5)
  187.            | ((xmc[19] & 0x7) << 2)
  188.            | ((xmc[20] >> 1) & 0x3);
  189.     *c++ =   ((xmc[20] & 0x1) << 7)
  190.            | ((xmc[21] & 0x7) << 4)
  191.            | ((xmc[22] & 0x7) << 1)
  192.            | ((xmc[23] >> 2) & 0x1);
  193.     *c++ =   ((xmc[23] & 0x3) << 6)
  194.            | ((xmc[24] & 0x7) << 3)
  195.            | (xmc[25] & 0x7);
  196.  
  197. #undef    Nc
  198. #define    Nc    (source + 42 - 2) 
  199.  
  200.     *c++ =   ((Nc[2] & 0x7F) << 1)            /* 20 */
  201.  
  202. #undef    bc
  203. #define    bc    (source + 43 - 2)
  204.  
  205.            | ((bc[2] >> 1) & 0x1);
  206.     *c++ =   ((bc[2] & 0x1) << 7)
  207.  
  208. #undef    Mc
  209. #define    Mc    (source + 44 - 2)
  210.  
  211.            | ((Mc[2] & 0x3) << 5)
  212.  
  213. #undef    xmaxc
  214. #define    xmaxc    (source + 45 - 2)
  215.  
  216.            | ((xmaxc[2] >> 1) & 0x1F);
  217.     *c++ =   ((xmaxc[2] & 0x1) << 7)
  218.  
  219. #undef    xmc
  220. #define    xmc    (source + 46 - 26)
  221.  
  222.            | ((xmc[26] & 0x7) << 4)
  223.            | ((xmc[27] & 0x7) << 1)
  224.            | ((xmc[28] >> 2) & 0x1);
  225.     *c++ =   ((xmc[28] & 0x3) << 6)
  226.            | ((xmc[29] & 0x7) << 3)
  227.            | (xmc[30] & 0x7);
  228.     *c++ =   ((xmc[31] & 0x7) << 5)
  229.            | ((xmc[32] & 0x7) << 2)
  230.            | ((xmc[33] >> 1) & 0x3);
  231.     *c++ =   ((xmc[33] & 0x1) << 7)
  232.            | ((xmc[34] & 0x7) << 4)
  233.            | ((xmc[35] & 0x7) << 1)
  234.            | ((xmc[36] >> 2) & 0x1);
  235.     *c++ =   ((xmc[36] & 0x3) << 6)
  236.            | ((xmc[37] & 0x7) << 3)
  237.            | (xmc[38] & 0x7);
  238.  
  239. #undef    Nc
  240. #define    Nc    (source + 59 - 3)
  241.  
  242.     *c++ =   ((Nc[3] & 0x7F) << 1)
  243.  
  244. #undef    bc
  245. #define    bc    (source + 60 - 3)
  246.  
  247.            | ((bc[3] >> 1) & 0x1);
  248.     *c++ =   ((bc[3] & 0x1) << 7)
  249.  
  250. #undef    Mc
  251. #define    Mc    (source + 61 - 3)
  252.  
  253.            | ((Mc[3] & 0x3) << 5)
  254.  
  255. #undef    xmaxc
  256. #define    xmaxc    (source + 62 - 3)
  257.  
  258.            | ((xmaxc[3] >> 1) & 0x1F);
  259.     *c++ =   ((xmaxc[3] & 0x1) << 7)
  260.  
  261. #undef    xmc
  262. #define    xmc    (source + 63 - 39)
  263.  
  264.            | ((xmc[39] & 0x7) << 4)
  265.            | ((xmc[40] & 0x7) << 1)
  266.            | ((xmc[41] >> 2) & 0x1);
  267.     *c++ =   ((xmc[41] & 0x3) << 6)            /* 30 */
  268.            | ((xmc[42] & 0x7) << 3)
  269.            | (xmc[43] & 0x7);
  270.     *c++ =   ((xmc[44] & 0x7) << 5)
  271.            | ((xmc[45] & 0x7) << 2)
  272.            | ((xmc[46] >> 1) & 0x3);
  273.     *c++ =   ((xmc[46] & 0x1) << 7)
  274.            | ((xmc[47] & 0x7) << 4)
  275.            | ((xmc[48] & 0x7) << 1)
  276.            | ((xmc[49] >> 2) & 0x1);
  277.     *c++ =   ((xmc[49] & 0x3) << 6)
  278.            | ((xmc[50] & 0x7) << 3)
  279.            | (xmc[51] & 0x7);
  280. }
  281.